/*
 * @(#)cn.design.pattern.state 2020/4/27/0027
 *
 * Copy Right@ 人人译视界
 */


package cn.design.pattern.state;

/**
 * <pre>
 * @author tuwei
 *
 * @version 0.9
 *
 * 修改版本: 0.9
 * 修改日期: 2020/4/27/0027
 * 修改人 :  tuwei
 * 修改说明: 初步完成
 * 复审人 ：
 * </pre>
 */
public class RaffleActivity {
	// 活动当前的状态，是变化的
	State state = null;
	// 奖品数量
	int count = 0;

	State noRaffleState = new NoRaffleState(this);
	State canRaffleState = new CanRaffleState(this);
	State dispenseState = new DispenseState(this);
	State dispenseOutState = new DispenseOutState(this);

	// 初始化当前状态为不能抽奖状态
	public RaffleActivity(int count) {
		this.state = getNoRaffleState();
		this.count = count;
	}

	public void debuctMoney() {
		state.deduceMoney();
	}

	public void raffle() {
		if(state.raffle()) {
			state.dispensePrize();
		}
	}

	public State getState() {
		return state;
	}

	public void setState(State state) {
		this.state = state;
	}

	public int getCount() {
		// 每领取一次奖品，count--
		int curCount = count;
		count--;
		return curCount;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public State getNoRaffleState() {
		return noRaffleState;
	}

	public void setNoRaffleState(State noRaffleState) {
		this.noRaffleState = noRaffleState;
	}

	public State getCanRaffleState() {
		return canRaffleState;
	}

	public void setCanRaffleState(State canRaffleState) {
		this.canRaffleState = canRaffleState;
	}

	public State getDispenseState() {
		return dispenseState;
	}

	public void setDispenseState(State dispenseState) {
		this.dispenseState = dispenseState;
	}

	public State getDispenseOutState() {
		return dispenseOutState;
	}

	public void setDispenseOutState(State dispenseOutState) {
		this.dispenseOutState = dispenseOutState;
	}
}
